#define _CRT_SECURE_NO_WARNINGS 
#include "qsort_bubble.h"
struct Stu {
	char name[10];
	int age;
}d[] = { "zhangsan",25,"lisi",65,"wangwu",16,"laoliu",18 };
void Print1(int* p, int num)
{
	for (int i = 0; i < num; i++)
	{
		printf("%d ", *(p + i));
	}
	printf("\n");
}void Print2(char* p, int num)
{
	for (int i = 0; i < num; i++)
	{
		printf("%c ", *(p + i));
	}
	printf("\n");
}void Print3(double* p, int num)
{
	for (int i = 0; i < num; i++)
	{
		printf("%.2lf ", *(p + i));
	}
	printf("\n");
}void Print4(struct Stu* p, int num)
{
	for (int i = 0; i < num; i++)
	{
		printf("%s %d\n", (p + i)->name, (p + i)->age);
	}
	printf("\n");
}
int cmp_int(const void* x, const void* y)
{
	return *(int*)x - *(int*)y;
}
int cmp_char(const void* x, const void* y)
{
	return *(char*)x - *(char*)y;
}
int cmp_double(const void* x, const void* y)
{
	return *(double*)x - *(double*)y;
}
int cmp_Struct_Stu_by_Name(const void* x, const void* y)
{
	return strcmp((*(struct Stu*)x).name, (*(struct Stu*)y).name);
}
int cmp_Struct_Stu_by_Age(const void* x, const void* y)
{
	return (*(struct Stu*)x).age - (*(struct Stu*)y).age;
}
int main()
{
	int a[] = { 5,3,2,7,8,1,9,4,5,6 };
	int sz_a = sizeof(a) / sizeof(a[0]);
	qsort_bubble(a, sz_a, sizeof(a[0]), cmp_int);
	Print1(a, sz_a);
	char b[] = { 'b','e','g','a','c','f','d','\0' };
	int sz_b = strlen(b);
	qsort_bubble(b, sz_b, sizeof(b[0]), cmp_char);
	Print2(b, sz_b);
	double c[] = { 4.1,5.3,9.99,1.5 };
	int sz_c = sizeof(c) / sizeof(c[0]);
	qsort_bubble(c, sz_c, sizeof(c[0]), cmp_double);
	Print3(c, sz_c);
	int sz_d = sizeof(d) / sizeof(d[0]);
	qsort_bubble(d, sz_d, sizeof(d[0]), cmp_Struct_Stu_by_Name);
	Print4(d, sz_d);
	qsort_bubble(d, sz_d, sizeof(d[0]), cmp_Struct_Stu_by_Age);
	Print4(d, sz_d);
	return 0;
}
